<template>
  <div class="list-container">
    <h1>本网站搜录的作者</h1>
    <div class="list">
      <!-- 作者列表 -->
      <el-tag
          v-for="author in filteredAuthors"
          :key="author"
          type="info"
          @click.native="goToAuthor(author)"
      >
        {{ author }}
      </el-tag>
    </div>
  </div>
</template>

<script>
import { books } from "@/assets/data/booksData";
import '@/assets/css/List.css';

export default {
  name: 'AuthorList',
  computed: {
    filteredAuthors() {
      const allAuthors = books.flatMap(book => book.author);
      return [...new Set(allAuthors)];
    },
  },
  methods: {
    goToAuthor(author) {
      this.$router.push({ path: `/authordetail/${author}` });
    },
  },
};
</script>
